import React, { useState, useEffect } from 'react'
import { View, Text } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { AtGrid } from 'taro-ui'
import './cookbook.scss'

export default function index() {
  const [data, setData] = useState([])

  useEffect(() => {
    Taro.request({
      url: 'http://localhost:9000/hotcat',
      success: (result) => {
        setData(result.data)
      }
    })
  }, [])

  return (
    <View className="hotcate-wrap">
      <View className="hotcate-wrap__title">
        热门分类
      </View>
      <AtGrid
        mode='rect' 
        hasBorder={false} 
        data={data}
      />
    </View>
  )
}